package org.example.model;

import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class Order {
    public List<OrderItem> orderItems = new ArrayList<>();
    public int total = 0, pickupCounter = 0;
    public double totalPrice = 0;
    public String mailbox;
    public String condition = "", date;
    public Order() {}
    public Order(Order order, String condition) {
        this.orderItems = order.orderItems;
        this.mailbox = order.mailbox;
        this.total = order.total;
        this.totalPrice = order.totalPrice;
        this.date = order.date;
        this.condition = condition;
    }
    public void setDate() {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        date = dateFormat.format(calendar.getTime());
    }
    public void setTotal() {
        for (OrderItem item : orderItems) {
            total += item.number;
        }
    }
    public void setTotalPrice() {
        for (OrderItem item : orderItems) {
            totalPrice += item.number * item.price;
        }
    }

}
